﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
        }

        #l-map {
            height: 100%;
            width: 78%;
            float: left;
            border-right: 2px solid #bcbcbc;
        }

        #r-result {
            height: 100%;
            width: 20%;
            float: left;
        }
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/DistanceTool/1.2/src/DistanceTool_min.js"></script>
    <link href="../Style/Css/Page.css" rel="stylesheet" type="text/css" />
    <title>添加缩放平移控件</title>
</head>
<body>
    <div class="container">
        <div id="gridmenu">
            <span><a>放大</a> <em>|</em><a>缩小</a> <em>|</em><a>平移</a> <em>|</em><a onclick="DistanceTool()">测距</a></span>
        </div>
    </div>
    <div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
    var map = new BMap.Map("allmap");
    // map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);

    map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
    map.addControl(new BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT }));

    map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用

    map.centerAndZoom("重庆", 12);                   // 初始化地图,设置城市和地图级别。
    var myDis = new BMapLib.DistanceTool(map);
    map.addEventListener("load", function () {
        //    //开启鼠标测距
        //myDis.close();  //关闭鼠标测距大
    });


    map.enableDragging();   //三秒后开启拖拽
    //map.enableInertialDragging();   //三秒后开启惯性拖拽

    function DistanceTool() {
        myDis.open();
    }
</script>
